package com.timing.feedback.auth;


import com.timing.feedback.utils.WriteJsonUtil;
import com.timing.feedback.vo.ResultVO;
import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import java.io.IOException;

/**
 * <p>
 *
 * </p>
 *
 * @author: cwh
 * @since 2021-05-20
 */
@Component("webExpiredSessionStrategy")
public class WebExpiredSessionStrategy implements SessionInformationExpiredStrategy {

    @Override
    public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
        WriteJsonUtil.writeJson(event.getRequest(),event.getResponse(), ResultVO.error().data("message","您的账号在别处登录"));
    }
}
